package com.hangxiang.approval.controller;

import com.hangxiang.approval.common.CcPersonInsertCommon;
import com.hangxiang.approval.common.CcPersonUpdateCommon;
import com.hangxiang.approval.common.IntegerCommon;
import com.hangxiang.approval.common.ResultBean;
import com.hangxiang.approval.service.CcPersonService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (CcPerson)表控制层
 *
 * @author makejava
 * @since 2020-11-24 15:03:56
 */
@RestController
@RequestMapping("ccPerson")
@Api(tags = "用户抄送人相关功能")
public class CcPersonController {
    /**
     * 服务对象
     */
    @Resource
    private CcPersonService ccPersonService;

    /**
     * 通过主键查询单条数据
     *
     * @param common 主键
     * @return 单条数据
     */
    @PostMapping("selectOne")
    @ApiOperation(value = "通过主键查询单条数据")
    @ResponseBody
    public ResultBean selectOne(@RequestBody @Validated IntegerCommon common) {
        return ResultBean.success(ccPersonService.queryById(common));
    }

    /**
     * 新增数据
     *
     * @param ccPersonInsertCommon 实例对象
     * @return 实例对象
     */
    @PostMapping("insertCcPerson")
    @ApiOperation(value = "添加数据")
    @ResponseBody
    public ResultBean insertCcPerson(@RequestBody @Validated CcPersonInsertCommon ccPersonInsertCommon) {
        return ResultBean.success(ccPersonService.insertCcPerson(ccPersonInsertCommon));
    }

    /**
     * 新增数据
     *
     * @param ccPersonUpdateCommon 实例对象
     * @return 实例对象
     */
    @PostMapping("updateCcPerson")
    @ApiOperation(value = "修改数据")
    @ResponseBody
    public ResultBean updateCcPerson(@RequestBody @Validated CcPersonUpdateCommon ccPersonUpdateCommon) {
        return ResultBean.success(ccPersonService.updateCcPerson(ccPersonUpdateCommon));
    }


}